const bodyParser = require('body-parser')
const express = require('express')
const {register} = require('./personal_modules/register.js')
const {login} = require('./personal_modules/login.js')
const session = require('express-session')
const getUser = require('./personal_modules/getUser')
const upload = require('./personal_modules/upload')

const multer = require('multer')
const upload_path = multer({dest:'./user_upload'})

const setUser = require('./personal_modules/setUser')

const app = express()

app.listen(65535,()=>{
    console.log('Server is running...')
})

app.use(upload_path.any())

app.use(bodyParser.urlencoded({extended:false}))

app.use(express.static('./user_upload'))
app.use(express.static('./www'))

app.use(session({
    secret:'我就是加密内容',
    resave:false,
    saveUninitialized:true,
    cookie:{maxAge:1000 * 10}
}))

app.get('/login',login('成功调用login函数'))

app.post('/register',register('成功调用register函数'))

app.get('/getUser',getUser())

app.post('/upload',upload())

app.post('/setUser',setUser())